home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Graphics Unleashed
/
PC Graphics Unleashed.iso
/
ch08
/
clip.c
next >
Wrap
C/C++ Source or Header
|
1994-09-15
|
1KB
|
46 lines
// CLIP.C
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#define CLIP_ON 1
#define CLIP_OFF 0
void main(void) {
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
setcolor(getmaxcolor());
/* draw box around viewport #1 */
rectangle(0,0,100,100);
/* draw box around viewport #2 */
rectangle(200,0,300,100);
/* set viewport #1 */
setviewport(0,0,100,100,CLIP_OFF);
/* draw a circle inside it */
circle(60,50,50);
/* set viewport #2 */
setviewport(200, 0, 300, 100, CLIP_ON);
/* draw a circle inside it */
circle(60,50,50);
getch();
closegraph();
}